<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="./js/react.js"></script>
    <script src="./js/react-dom.js"></script>
    <script src="./js/babel.min.js"></script>
    <title>Document</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      const stars = [
        { id: 1, name: '科比1' },
        { id: 2, name: '詹姆斯2' },
        { id: 3, name: '库里3' },
      ]

      const movieStar = [
        { id: 1, name: '邓超', sex: 1 },
        { id: 2, name: '孙俪', sex: 0 },
        { id: 3, name: '邓紫棋', sex: 0 },
        { id: 4, name: '周杰伦', sex: 1 },
      ]

      let lis = stars.map((item) => <li key={item.id}>{item.name}</li>)

      let manStars = movieStar.filter((item) => item.sex === 1)

      // 最终循环要在map中返回jsx数组
      let movielis = manStars.map((item) => <li key={item.id}>{item.name}</li>)

      const appVnode = (
        <>
          <h3>球星</h3>
          <ul>{lis}</ul>
          <h3>影视明星</h3>
          <ul>{movielis}</ul>
        </>
      )

      // 将虚拟节点插入到dom树中
      ReactDOM.createRoot(document.getElementById('root')).render(appVnode)
    </script>
  </body>
</html>
